package org.dromara.common.core.domain.model

import jakarta.validation.constraints.NotBlank
import org.hibernate.validator.constraints.Length

/**
 * 密码登录对象
 *
 *@author LikeYouDo
 *@date 2025/1/3 10:59
 */
data class PasswordLoginBody(
    /**
     * 用户名
     */
    @field:NotBlank(message = "{user.username.not.blank}")
    @field:Length(min = 2, max = 30, message = "{user.username.length.valid}")
    var username: String = "",

    /**
     * 用户密码
     */
    @field:NotBlank(message = "{user.password.not.blank}")
    @field:Length(min = 5, max = 30, message = "{user.password.length.valid}")
    // @Pattern(regexp = RegexConstants.PASSWORD, message = "{user.password.format.valid}")
    var password: String = "",
) : LoginBody() {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other !is PasswordLoginBody) return false
        if (!super.equals(other)) return false

        if (username != other.username) return false
        if (password != other.password) return false

        return true
    }

    override fun hashCode(): Int {
        var result = super.hashCode()
        result = 31 * result + username.hashCode()
        result = 31 * result + password.hashCode()
        return result
    }
}
